
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SKHYNIX_VCBD_H
#define __SKHYNIX_VCBD_H

/* Includes ------------------------------------------------------------------*/
#include "stm32f37x.h"
#include <stdio.h>	/* for printf */
#include "display.h"

/* Exported constants --------------------------------------------------------*/
#define STR_TITLE	"SKHynix VCBD v0.95"
enum {
	MODE_UNKNOW=-1,
	MODE_READY,
	MODE_REMOTE,
	MODE_REMOTE_VI2MD,
	MODE_DACOUT,
	MODE_ADCIN,
	MODE_SETUP,
	MODE_CALIBRATION,

	VOUT_1=0, VOUT_2, VOUT_3, VOUT_MAX,

	VDATA_TOFF=0,
	VDATA_TR1, VDATA_VR1,
	VDATA_TR2, VDATA_VR2,
	VDATA_TR3, VDATA_VR3,
	VDATA_TR4, VDATA_VR4,
	VDATA_TON,
	VDATA_TF1,
	VDATA_OFFSET,
	VDATA_RESERVED,
	VDATA_MAX,
	VDATA_TR_STEP=4,
};

/* Exported types ------------------------------------------------------------*/
typedef uint8_t			BYTE;
typedef uint16_t		WORD;
typedef long			LONG;
typedef uint32_t		DWORD;
typedef unsigned long	ULONG_PTR, *PULONG_PTR;
typedef ULONG_PTR		DWORD_PTR, *PDWORD_PTR;

typedef struct {
	DWORD	dwToff;		// VDATA_TOFF	[mS]
	DWORD	dwTr1;		// VDATA_TR1	[uS]
	DWORD	dwVr1;		// VDATA_VR1	[mV]
	DWORD	dwTr2;		// VDATA_TR2	[uS]
	DWORD	dwVr2;		// VDATA_VR2	[mV]
	DWORD	dwTr3;		// VDATA_TR3	[uS]
	DWORD	dwVr3;		// VDATA_VR3	[mV]
	DWORD	dwTr4;		// VDATA_TR4	[uS]
	DWORD	dwVr4;		// VDATA_VR4	[mV]
	DWORD	dwTon;		// VDATA_TON	[mS]
	DWORD	dwTf1;		// VDATA_TF1	[uS]
	DWORD	dwOffset;	// VDATA_OFFSET
	DWORD	dwReserved;	// VDATA_RESERVED
} VOUT_DATA, *PVOUT_DATA;

typedef u32 (*fxCMDLINE)(int argc);
typedef struct {
	const char 	*cmd;
	const int	cmdLength;
	fxCMDLINE	fx;
} CMDLINE_CB, *PCMDLINE_CB;

typedef void (*fxMODE)(u8 key, u32 first);
typedef struct {
	const int	mode;
	fxMODE		fx;
} MODE_CB, *PMODE_CB;

/* Exported macro ------------------------------------------------------------*/
#ifndef	_countof
#define _countof(a)		(sizeof(a) / sizeof(a[0]))
#endif
#ifndef _max
#define _max(a,b)		(((a) > (b)) ? (a) : (b))
#endif
#ifndef _min
#define _min(a,b)		(((a) < (b)) ? (a) : (b))
#endif

#ifndef	MAKEWORD
#define MAKEWORD(l,h)	((WORD)(((BYTE)(((DWORD_PTR)(l)) & 0xff)) | ((WORD)((BYTE)(((DWORD_PTR)(h)) & 0xff))) << 8))
#endif
#ifndef	MAKELONG
#define MAKELONG(l,h)	((LONG)(((WORD)(((DWORD_PTR)(l)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(h)) & 0xffff))) << 16))
#endif
#ifndef	LOWORD
#define LOWORD(l)		((WORD)(((DWORD_PTR)(l)) & 0xffff))
#endif
#ifndef	HIWORD
#define HIWORD(l)		((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
#endif
#ifndef	LOBYTE
#define LOBYTE(w)		((BYTE)(((DWORD_PTR)(w)) & 0xff))
#endif
#ifndef	HIBYTE
#define HIBYTE(w)		((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
#endif

/* Exported variables ---------------------------------------------------------*/
extern vu32 gvSysTickCount;
extern vu32 gvCurMode;
extern VOUT_DATA gVout[VOUT_MAX];
extern char gszLine[LCD_MAX_CHAR+1];


/* Exported functions ------------------------------------------------------- */

#endif  /* __SKHYNIX_VCBD_H */
